package com.autoreassociate.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import com.autoreassociate.SettingActivity;
import com.autoreassociate.service.CaLifeCycleService;

public class StartAppControlReceiver extends BroadcastReceiver {
	
	
	@Override
	public void onReceive(Context context, Intent intent) {
		
		SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
		
		if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
            
			if (!preferences.getBoolean(SettingActivity.BROADCAST_AUTO_START_WHEN_BOOT_UP, false)) {
				return;
			}
			
			//Intent activityIntent = new Intent(context, MainActivity.class);    
			//activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
	        //context.startActivity(activityIntent);

			//ConnectionAssociateTool 
			//connectionAssociateTool = 
			//	ConnectionAssociateTool.getInstance(context.getApplicationContext());
	        
	        
	        context.startService(new Intent(context, CaLifeCycleService.class));
			//context.bindService(new Intent(context, CaLifeCycleService.class), conn, context.BIND_AUTO_CREATE)
		}

	}

}
